<?php
defined('OA_LIB_PATH') || define('OA_LIB_PATH', '/opt/op/OALib');
defined('OPEN_LIB_PATH') || define('OPEN_LIB_PATH', '/opt/op/OpenLib');

require_once 'PHPUnit/Framework.php';
require_once 'Log.php';
require_once OPEN_LIB_PATH . '/open/models/OaAppConfigOrderModel.php';

class OaAppConfigOrderModelTest extends PHPUnit_Framework_TestCase
{
    private $_logger;
    private $_model;
    
    protected function setUp()
    {
        $logger = Log::factory('console', '', '', array(), PEAR_LOG_INFO);
        $this->_logger = $logger;
        $this->_model = new OaAppConfigOrderModel($logger);
    }
    
    protected function tearDown()
    {
        
    }
    
    /**
     * @dataProvider provider
     */
    public function testCreateConfigOrder($orderId)
    {
        $this->markTestSkipped();
        $result = $this->_model->createConfigOrder($orderId, 1, 'jaggerwang');
        $this->assertTrue($result > 0);
    }
    
    /**
     * @dataProvider provider
     */
    public function testCreateConfigTask($orderId)
    {
        $this->markTestSkipped();
        $result = $this->_model->createConfigTask($orderId, 'open_login_service', array('login service data'));
        $this->assertTrue($result > 0);
        $result = $this->_model->createConfigTask($orderId, 'open_ibw_service');
        $this->assertTrue($result > 0);
    }
    
    public function testGetAppConfigOrders()
    {
        $this->markTestSkipped();
        $result = $this->_model->getAppConfigOrders(1);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue(is_array($result));
    }
    
    public function testGetAppCurrentConfigOrder()
    {
        $this->markTestSkipped();
        $result = $this->_model->getAppCurrentConfigOrder(1);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result !== false);
    }
    
    /**
     * @dataProvider provider
     */
    public function testSetConfigOrderStatus($orderId)
    {
        $this->markTestSkipped();
        $result = $this->_model->setConfigOrderStatus($orderId, OaAppConfigOrderModel::CONFIG_ORDER_STATUS_IN_OPERATION);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result !== false);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetConfigOrder($orderId)
    {
        $this->markTestSkipped();
        $result = $this->_model->getConfigOrder($orderId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result !== false);
    }
    
    /**
     * @dataProvider provider
     */
    public function testAddOpenServiceRequest($orderId)
    {
        $this->markTestSkipped();
        $result = $this->_model->addOpenServiceRequest($orderId);
        $this->_logger->log($result, PEAR_LOG_DEBUG);
        $this->assertTrue($result > 0);
    }
    
    /**
     * @dataProvider provider
     */
    public function testGetConfigOrderTasksOfService($orderId)
    {
        $result = $this->_model->getConfigOrderTasksOfService($orderId, 
        	OaAppModel::APP_SERVICE_TYPE_BILLING);
        $this->_logger->log($result, PEAR_LOG_INFO);
        $this->assertTrue($result > 0);
    }
    
    public function provider()
    {
        return array(
            array('OpenProcess.70086')
        );
    }
}